<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src='../js/旧版本/react.development.js'></script>
    <script src='../js/旧版本/react-dom.development.js'></script>
    <script src='../js/旧版本/babel.min.js'></script>
    <script src='../js/旧版本/prop-types.js'></script>
</head>

<body>
    <div id="test"></div>
    <div id="test2"></div>
    <script type='text/babel'>
        function Person(props) {
            const { name, sex, age } = props
            return (
                <ul>
                    <li>{name}</li>
                    <li>{sex}</li>
                    <li>{age}</li>
                </ul>
            )
        }
        // 限制规则
        Person.propTypes = {
            name: PropTypes.string.isRequired, // 限制name类型为string类型，且必需
            sex: PropTypes.string,
            age: PropTypes.number,
            speak: PropTypes.func
        },
            // 默认值
            Person.defaultProps = {
                sex: '人妖'
            }
        const p = { name: '张三', sex: '男', age: 20 }
        function speak() { console.log('speak') }
        ReactDOM.render(<Person name='阿古拉' age={12} />, document.querySelector('#test'))
        ReactDOM.render(<Person {...p} speak={speak} />, document.querySelector('#test2'))
    </script>
</body>

</html>